home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / sm_macro.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.3 KB  |  139 lines

  1. #ifndef _SM_MACRO_H_
  2. #define _SM_MACRO_H_
  3. /*
  4.  *   $RCSfile: sm_macro.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:08 $      
  7.  */ 
  8. /**********************************************************************
  9. * EXODUS Database Toolkit Software
  10. * Copyright (c) 1991 Computer Sciences Department, University of
  11. *                    Wisconsin -- Madison
  12. * All Rights Reserved.
  13. *
  14. * Permission to use, copy, modify and distribute this software and its
  15. * documentation is hereby granted, provided that both the copyright
  16. * notice and this permission notice appear in all copies of the
  17. * software, derivative works or modified versions, and any portions
  18. * thereof, and that both notices appear in supporting documentation.
  19. *
  20. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  21. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  22. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  23. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  24. *
  25. * The EXODUS Project Group requests users of this software to return 
  26. * any improvements or extensions that they make to:
  27. *
  28. *   EXODUS Project Group 
  29. *     c/o David J. DeWitt and Michael J. Carey
  30. *   Computer Sciences Department
  31. *   University of Wisconsin -- Madison
  32. *   Madison, WI 53706
  33. *
  34. *     or exodus@cs.wisc.edu
  35. *
  36. * In addition, the EXODUS Project Group requests that users grant the 
  37. * Computer Sciences Department rights to redistribute these changes.
  38. **********************************************************************/
  39.  
  40. /* BEGIN visible to E */
  41.  
  42. /*
  43.  * sm_macro.h
  44.  *     macros for the sm module.
  45.  */
  46.  
  47.  
  48. /*
  49.  * Macro to initialize a slotted page.
  50.  */
  51. #define INITPAGE(_pagePtr, _pid, _fid, _marked, _unique)        \
  52.         (_pagePtr)->header.freeStart         = 0;                            \
  53.         (_pagePtr)->header.freeBytes         = INITIALLYFREE;                \
  54.         (_pagePtr)->header.freeSlot             = NIL;                            \
  55.         (_pagePtr)->header.slotCount         = 0;                            \
  56.         (_pagePtr)->header.pid                 = _pid;                        \
  57.         (_pagePtr)->header.fid                 = _fid;                        \
  58.         (_pagePtr)->header.neighborPid.volid = NIL;                            \
  59.         (_pagePtr)->header.nextLogicalPid     = NULLPID;                        \
  60.         (_pagePtr)->header.largeCount         = (_marked) ? 1 : 0;            \
  61.         (_pagePtr)->header.uniqueCount         = UNIQUE_ALLOC_COUNT;            \
  62.         (_pagePtr)->header.unique             = _unique;                        \
  63.         (_pagePtr)->header.magic             = SLOT_PAGE_MAGIC;                \
  64.         (_pagePtr)->slot[0].offset             = NIL;
  65.  
  66.  
  67. /*
  68.  * Macro to calculate the amount of continguous free space on a slotted page.
  69.  */
  70. #define CONTIGSPACE(_pagePtr)                                                \
  71.             ((int)sizeof(SLOTTEDPAGE) - ((_pagePtr)->header.freeStart +                    \
  72.             (int)sizeof(SLOTTEDHEADER) + ((_pagePtr)->header.slotCount * (int)sizeof(PAGESLOT))))
  73.  
  74. /*
  75.  *    macro to get a pointer to the slot
  76.  */
  77. #define GETSLOTPTR(_pagePtr, _slotIndex)            \
  78.         (&((_pagePtr)->slot[-(_slotIndex)]))
  79.  
  80. /*
  81.  * Macro to calculate the address of a generic object on
  82.  * a slotted page.
  83.  */
  84. #define GETOBJECTPTR(_pagePtr, _slotPtr)                        \
  85.         ((OBJECT *) ((char *) (_pagePtr) + ((_slotPtr)->offset)))
  86.  
  87. /*
  88.  * Macro to calculate the address of an small object on
  89.  * a slotted page.
  90.  */
  91. #define SMALLOBJPTR(_pagePtr, _slot)                    \
  92.         ((SMALLOBJ *) ((char *) _pagePtr + (_pagePtr)->slot[-_slot]))
  93.  
  94. /*
  95.  * Macro to calculate the address of an large object on
  96.  * a slotted page.
  97.  */
  98. #define LARGEOBJPTR(_pagePtr, _slot)                    \
  99.         ((LARGEOBJ *) ((char *) _pagePtr + (_pagePtr)->slot[-_slot]))
  100.  
  101.  
  102. /*
  103.  * Macro to check if we have a valid oid.
  104.  */
  105. #define CHECKOID(_objSlot, _pagePtr, _slotPtr, _unique)                \
  106.                                                                     \
  107.         ((_objSlot < 0) ||                                            \
  108.         (_objSlot >= (_pagePtr)->header.slotCount) ||                \
  109.         (_slotPtr->offset == NIL) ||                                \
  110.         (_slotPtr->unique != _unique))
  111.  
  112.  
  113. #define    OIDEQ(_oid1, _oid2)                                         \
  114.         ( ((_oid1).diskAddr.unique     == (_oid2).diskAddr.unique) &&    \
  115.           ((_oid1).diskAddr.slot     == (_oid2).diskAddr.slot) &&    \
  116.           ((_oid1).diskAddr.page     == (_oid2).diskAddr.page) &&    \
  117.           ((_oid1).diskAddr.volid    == (_oid2).diskAddr.volid) )
  118.  
  119.  
  120. #define CHECK_SLOTTED_MAGIC(_slottedPage)                \
  121.                                                         \
  122.     ((_slottedPage)->header.magic != SLOT_PAGE_MAGIC)
  123.  
  124.  
  125. /*
  126.  *    Objects with these flags set are invisible to the user
  127.  */
  128. #define INVISIBLE_OBJECT (P_HISTORYGRAPH | P_FORWARD | P_DESTROYPENDING)
  129.  
  130. /* END visible to E */
  131.  
  132. /* BEGIN visible to user */
  133. /*
  134.  *    define flags for opening a buffer group
  135.  */
  136. #define TRANS_GROUP        0x1
  137. /* END visible to user */
  138. #endif /* _SM_MACRO_H_ */
  139.